#include "pch.h"
#include "World.h"

void GravityTest()
{
    Physics::World world;
    world.Create();

    Physics::RigidBody rb1 = world.CreateRigidBody(glm::vec3(0.1f, 2.0f, 0.1f));
    rb1.AddBoxCollider(glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(0.0f));

    Physics::RigidBody ground = world.CreateRigidBody(glm::vec3(0.0f, -10.0f, 0.0f));
    ground.AddBoxCollider(glm::vec3(100.0f, 0.f, 100.0f), glm::vec3(0.0f, 0.0f, 0.0f));

    ground.SetBodyType(Physics::RigidBody::Type::KINEMATIC);

    while (1)
    {
        world.Update(0.0001f);

        glm::vec3 pos;
        glm::quat rot;
        rb1.GetTransform(pos, rot);
        PY_LOGI("pos %f %f %f", pos.x, pos.y, pos.z);
    }

    world.Destory();
};

int main()
{

    // rp3d::PhysicsCommon py;
    // rp3d::PhysicsWorld *world = py.createPhysicsWorld();

    // rp3d::Transform t1;

    // t1.setPosition({0.1, 0.1, 0.1f});
    // rp3d::RigidBody *b1 = world->createRigidBody(t1);

    // t1.setPosition({0.1f, -0.1f, -0.1f});
    // rp3d::RigidBody *b2 = world->createRigidBody(t1);

    // rp3d::BallAndSocketJointInfo jointInfo(b1, b2, rp3d::Vector3(0.0f, 0.f, 0.0f));
    // rp3d::BallAndSocketJoint *joint = static_cast<rp3d::BallAndSocketJoint *>(world->createJoint(jointInfo));

    // joint->enableConeLimit(true);
    // joint->setConeLimitHalfAngle(0.5f);
    // joint->isCollisionEnabled();

    // py.destroyPhysicsWorld(world);

    Physics::World world;
    world.Create();

    while (1)
    {
        world.Update(0.0001f);
    }

    world.Destory();
}